<template>
    <div class="com-cnt">
        <ul>
            
            <li class="inputli">
                <span><img src="@/assets/imgs/my/userhead.png" alt="姓名"></span><input type="text" placeholder="真实姓名" v-model="sfzxm">
            </li>
            <li class="inputli">
                <span><img src="@/assets/imgs/my/userid.png" alt="身份证号"></span><input type="text" placeholder="身份证号" v-model="sfzkh" onkeyup="this.value= this.value.match(/^[0-9]*$/) ? this.value.match(/^[0-9]*$/)[0] : ''">
            </li>
            <!-- <li class="inputli">
                <input type="text" placeholder="银行卡号" v-model="yhkh" onkeyup="this.value= this.value.match(/^[0-9]*$/) ? this.value.match(/^[0-9]*$/)[0] : ''">
            </li>
            <li class="inputli">
                <input type="text" placeholder="银行卡绑定手机号" v-model="yhkbdsjh" onkeyup="this.value= this.value.match(/^[0-9]*$/) ? this.value.match(/^[0-9]*$/)[0] : ''">
            </li> -->
            <li class="inputli">
                <button @click="smrz">确定</button>
            </li>
            
        </ul>
        <p class="tips">点击确定视为已阅读并同意
            <router-link :to="{path:'smregular'}" tag="span" style="color:blue">《蓄康荟会员规则》</router-link>
        </p>
    </div>
</template>
<script>
    import { domain } from '@/assets/js/config'
    import $ from 'jquery'
    import { maskTips,maskCallback } from '@/assets/js/dom'
    export default {
        name: 'shimingPage',
        components: {

        },
        data(){
            return{
                yhkh: '',
                sfzxm: '',
                sfzkh: '',
                yhkbdsjh: '',
                userToken: ''
            }
        },
        mounted ( ) {
            var that = this
            this.userToken = localStorage.getItem('token')
            maskCallback(function(){
                that.$router.go(-1)
            }, 'comp-mask-btnAleft-govip','comp-mask-btnAright')
            
        },
        methods : {
            smrz: function(){
                var that = this
                // 银行卡和手机号非必填
                var card = /^([1-9]{1})(\d{14}|\d{18}|\d{15})$/
                if(!card.test(this.yhkh)&&this.yhkh != ''){
                    maskTips({id:"card-error",txt:"请输入正确银行卡"})
                    return false
                }
                
                var ChineseName = /^([\u4e00-\u9fa5]){2,7}$/
                if(!ChineseName.test(this.sfzxm)){
                    maskTips({id:"name-error",txt:"请输入正确的姓名"})
                    return false
                }
                
                var idCard = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
                if(!idCard.test(this.sfzkh)){
                    maskTips({id:"id-error",txt:"请输入正确身份证卡号"})
                    return false
                }

                var phoneNo = /^[1][3,4,5,7,8][0-9]{9}$/
                if(!phoneNo.test(this.yhkbdsjh)&&this.yhkbdsjh != ''){
                    maskTips({id:"phoneNo-error",txt:"请输入正确手机号"})
                    return false
                }

                $.ajax({
                    type:"POST",
                    url:domain+"/xshk/f/bank_validate2?token="+this.userToken,
                    data:{mobile:this.yhkbdsjh,bankId:this.yhkh,userName:this.sfzxm,idCard:this.sfzkh},
                    dataType:"JSON",
                    success:function(data){
                        console.log(this)
                        var code = data.code;
                        var message = data.message;
                        console.log(data)
                        if(code==-3){
                            console.log(message);//
                            //window.open("${ctxF}/toBankValidate","_parent");
                            maskTips({id:"certification-fail-2",txt: message})
                        }else if(code!==0){
                            console.log(message);
                            maskTips({ id:"certification-fail" + new Date().getTime(),txt: message})
                        }else if(code === 0){
                            //maskTips({id:"certification-success",txt:"实名认证成功"})
                            localStorage.setItem('uthenticationStatus',3)
                            maskTips({ id: "certification-success"+ new Date().getTime(),title:'温馨提示',btnCls:'comp-mask-btnAleft-govip',btnTxt:'返回',btnTxt2:'取消', txt: "会员认证成功" })
                            // that.$router.push('/center')
                        }else{
                            console.log(message)
                        }
                    }
                })
            }
        }
    }
</script>

<style lang="stylus" scoped>
.com-cnt
    width 100%
    height 100%
    .tips
        font-size 12px
        padding-left 20px
        color #999
        margin-top 40px
    .inputli
        width 88.5%
        margin 0 auto
        height 40px
        border-bottom 1px solid #eee
        margin-top 20px
        input
            display block
            border none
            height 100%
            font-size 14px
            width 90%
            padding 0px 10px
            margin-bottom 15px
            line-height 21px
            float right
        span 
            width 22px
            height 22px
            color red
            font-size 22px
            display inline-block
            float left
            text-align center
            margin-top 10px
            img 
                width 100%
                height 100%
        button
            width: 100%;
            height: 100%;
            background: #aad114;
            border: none;
            color: #fff;
            font-size: 16px;
</style>